<template>
  <div id="pubNoticeDetailDialog">
    <el-dialog
      title="消息详情"
      :visible.sync="detailDialogData.isShow"
      width="700px"
    >
      <div class="form-box">
        <el-form
          :model="noticeDetail"
          label-width="120px"
          label-position="right"
        >
          <el-form-item label="触达时间">
            <el-input v-model="noticeDetail.touchTime" disabled></el-input>
          </el-form-item>
          <el-form-item label="触达通道">
            <el-select
              v-model="noticeDetail.touchType"
              disabled
              placeholder="请选择"
            >
              <el-option
                v-for="item in touchTypeList"
                :key="item.dictValue"
                :label="item.dictLabel"
                :value="item.dictValue"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            v-if="
              noticeDetail.touchType === 'PUSH' ||
                noticeDetail.touchType === 'NOTICE'
            "
            :label="
              noticeDetail.touchType === 'NOTICE' ? '站内信标题' : '推送标题'
            "
          >
            <el-input v-model="noticeDetail.title" disabled></el-input>
          </el-form-item>
          <el-form-item
            v-if="noticeDetail.touchType !== 'BOMB_SCREEN'"
            :label="
              noticeDetail.touchType === 'NOTICE' ? '站内信内容' : '推送内容'
            "
          >
            <el-input
              style="width: 500px"
              v-model="noticeDetail.content"
              disabled
              type="textarea"
              :rows="4"
              resize="none"
            ></el-input>
          </el-form-item>
          <el-form-item
            v-if="noticeDetail.touchType === 'BOMB_SCREEN'"
            label="弹屏图片"
          >
            <img
              v-if="noticeDetail.img"
              class="bomb-img"
              :src="noticeDetail.img"
              alt="弹屏图片"
            />
          </el-form-item>
          <el-form-item label="跳转链接">
            <el-input v-model="noticeDetail.url" disabled></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="success" @click="detailDialogData.isShow = false"
          >确 定</el-button
        >
        <el-button @click="detailDialogData.isShow = false">关 闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { sysNormalDisable } from '@utils/dictionariesFunc'
import { getNoticeDetailAPI } from '@/api/noticeManagement/noticeManage'
export default {
  props: ['detailDialogData'],
  data() {
    return {
      noticeId: '',
      noticeDetail: {},
      touchTypeList: []
    }
  },
  mounted() {
    this.noticeId = this.detailDialogData.noticeId
    this.getNoticeDetail()
    this.getTouchChannel()
  },
  methods: {
    // 获取详情
    getNoticeDetail() {
      getNoticeDetailAPI(
        this.noticeId,
        (response) => {
          this.noticeDetail = response
        },
        (response) => {
          this.$message({
            message: response.message,
            type: 'warning'
          })
        }
      )
    },
    // 获取触达通道
    async getTouchChannel() {
      const touchTypeList = await sysNormalDisable('activity_notice_type')
      this.touchTypeList = touchTypeList
    }
  }
}
</script>
<style lang="less">
#pubNoticeDetailDialog {
  .el-input {
    width: 500px !important;
  }
  .bomb-img {
    width: 178px;
    height: 178px;
  }
}
</style>
